#include "../corelib/util/aoi.hh"
#include "unittest/unittest.hh"

using namespace kratos::corelib;

FIXTURE_BEGIN(AoiScene)

TEARDOWN([]() {    
})

CASE(TestOverlappedCircle1) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapCircle(100, 100, 50, result);
    ASSERT_TRUE(result.size() == 2);
}

CASE(TestOverlappedCircle2) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapCircle(200, 200, 50, result);
    ASSERT_TRUE(result.size() == 0);
}

CASE(TestOverlappedCircle3) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapCircle(100, 100, 10, result);
    ASSERT_TRUE(result.size() == 1);
    ASSERT_TRUE(result[0]->getID() == 1);
}

CASE(TestOverlappedCircle4) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapCircle(100, 100, 10, result, 1);
    ASSERT_TRUE(result.size() == 0);
}

CASE(TestOverlappedCircle5) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapCircle(100, 100, 50, result, 1);
    ASSERT_TRUE(result.size() == 1);
    ASSERT_TRUE(result[0]->getID() == 2);
}

CASE(TestOverlappedSquare1) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapSquare(100, 100, 50, result);
    ASSERT_TRUE(result.size() == 2);
}

CASE(TestOverlappedSquare2) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapSquare(200, 200, 50, result);
    ASSERT_TRUE(result.size() == 0);
}

CASE(TestOverlappedSquare3) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapSquare(100, 100, 10, result);
    ASSERT_TRUE(result.size() == 1);
    ASSERT_TRUE(result[0]->getID() == 1);
}

CASE(TestOverlappedSquare4) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapSquare(100, 100, 10, result, 1);
    ASSERT_TRUE(result.size() == 0);
}

CASE(TestOverlappedSquare5) {
    AoiScene scene(0, 0, 1000, 1000, 50);
    scene.enter(1, 100, 100, 50);
    scene.enter(2, 120, 120, 50);
    EntityVector result;
    scene.overlapSquare(100, 100, 50, result, 1);
    ASSERT_TRUE(result.size() == 1);
    ASSERT_TRUE(result[0]->getID() == 2);
}

FIXTURE_END(AoiScene)
